<style>
    .el-form--inline .search-icon .el-form-item__content{width:168px;}
</style>
<template>
    <!--<h1>备件成本价</h1>-->
    <div class="spare-cost-price-page">
        <el-form ref="form" :model="spareCostPriceForm" :inline="true" style="margin-bottom:10px;border-bottom:1px solid #ccc;">
            <!--法人名称 @change="selectLegalPersonCode"-->
            <el-form-item :label="nowLangue.legalName" class="selectMB10 label-w1" >
                <el-select size="mini" clearable v-model="spareCostPriceForm.legalPersonCode"   :placeholder="nowLangue.pleaseSelect">
                    <el-option v-for="(legalPerson,index) in legalPersonLists" :key="index" :label="legalPerson.legalPersonName" :value="legalPerson.legalPersonCode">
                    </el-option>
                </el-select>
                <!--  v-if="legalPersonLists.length> 1" 
                <el-input size="mini" disabled v-else v-model="spareCostPriceForm.legalPersonName" placeholder=""></el-input>-->
            </el-form-item>
            <!--工厂-->
            <el-form-item :label="nowLangue.factory" class="purchase_label selectMB10 label-w1" >
                <el-select size="mini" v-if="factoryLists.length> 1" clearable v-model="spareCostPriceForm.legalPlantCode"  :placeholder="nowLangue.pleaseSelect">
                    <el-option v-for="(legalPlantCode,index) in factoryLists" :key="index" :label="legalPlantCode.legalPlantDec" :value="legalPlantCode.legalPlantCode">
                    </el-option>
                </el-select>
                <el-input size="mini" disabled v-else v-model="spareCostPriceForm.legalPlantCode" placeholder=""></el-input>
            </el-form-item>
            <!--备件编码-->
            <el-form-item :label="nowLangue.spareCode" class="purchase_label selectMB10 label-w1" >
                <el-input v-model="spareCostPriceForm.materialCode" :placeholder="nowLangue.pleaseImport+nowLangue.spareCode"  size="mini"></el-input>
            </el-form-item>
            <!--含税类型-->
            <el-form-item :label="nowLangue.taxType" class="purchase_label selectMB10 label-w1" >
                <el-select v-model="spareCostPriceForm.taxType" :placeholder="nowLangue.pleaseSelect" size="mini" clearable>
                    <el-option v-for="(taxType,index) in taxTypeLists" :key="index" :label="taxType.taxDec" :value="taxType.id">
                    </el-option>
                </el-select>
            </el-form-item>
            <!--价格分类-->
            <el-form-item :label="nowLangue.priceClassify" class="purchase_label selectMB10 label-w1" >
                <el-select v-model="spareCostPriceForm.priceType" :placeholder="nowLangue.pleaseSelect" size="mini" clearable>
                    <el-option v-for="(priceType,index) in selectDropDownValueObj" :key="index" :label="priceType.priceType" :value="priceType.priceType">
                    </el-option>
                </el-select>
            </el-form-item>
            <!--币别-->
            <el-form-item :label="nowLangue.currencyCode" class="purchase_label selectMB10 label-w1" >
                <el-select v-model="spareCostPriceForm.currencyCode" :placeholder="nowLangue.pleaseSelect" size="mini" clearable>
                    <el-option v-for="(currencyCode,index) in selectDropDownValueObj":key="index" :label="currencyCode.currencyCode" :value="currencyCode.currencyCode">
                    </el-option>
                </el-select>
            </el-form-item>
            <!--有效开始时间-->
            <el-form-item :label="nowLangue.effectiveStartTime" class="purchase_label selectMB10 label-w2" >
                <el-date-picker type="date" size="mini" :editable="false"  v-model="spareCostPriceForm.startStartTime":placeholder="nowLangue.pleaseSelect+nowLangue.effectiveStartTime" @change="selectedStartStartTime"></el-date-picker>
                &nbsp;<span v-text="nowLangue.to"></span>&nbsp;
                <el-date-picker type="date" size="mini" :editable="false" v-model="spareCostPriceForm.startEndTime" :placeholder="nowLangue.pleaseSelect+nowLangue.effectiveStartTime" @change="selectedStartEndTime"></el-date-picker>
            </el-form-item>
            <!--有效结束时间-->
            <el-form-item :label="nowLangue.effectiveEndTime" class="purchase_label selectMB10 label-w2" >
                <el-date-picker type="date" size="mini" :editable="false" v-model="spareCostPriceForm.endStartTime" :placeholder="nowLangue.pleaseSelect+nowLangue.effectiveStartTime" @change="selectedEndStartTime"></el-date-picker>
                &nbsp;<span v-text="nowLangue.to"></span>&nbsp;
                <el-date-picker type="date" size="mini" :editable="false" v-model="spareCostPriceForm.endEndTime" :placeholder="nowLangue.pleaseSelect+nowLangue.effectiveStartTime" @change="selectedEndEndTime"></el-date-picker>
            </el-form-item>
            <!--当前状态-->
            <el-form-item :label="nowLangue.status" class="purchase_label selectMB10 label-w1" >
                <el-select v-model="spareCostPriceForm.status" :placeholder="nowLangue.pleaseSelect" size="mini" clearable>
                    <el-option v-for="(status,index) in selectDropDownValueObj" :key="index" :label="status.label" :value="status.value">
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item class="purchase_label selectMB10">
                <!--查询-->
                <el-button type="danger" size="mini" class="searchBtn bolder outsideBtnBS selectAll" :disabled="selectDisabled" @click="handleQuery()" v-text="nowLangue.query"></el-button>
            </el-form-item>
        </el-form>
        <div class="block" style="margin-bottom: 10px">
            <!--价格明细：-->
            <span class="demonstration" style="font-weight: bold;" v-text="nowLangue.priceDetails"></span>
            <span class="wrapper">
                <!--  v-if="powerFlag1" -->
                <!--新增-->
                <el-button type="danger" size="mini" class="bolder searchBtn routerML30" @click="createNew" v-text="nowLangue.create"></el-button>
                <!--导入-->
               <el-button type="danger" size="mini" class="bolder searchBtn routerML30" @click="importFile" v-text="nowLangue.import"></el-button>
            </span>
        </div>
        <!--价格明细表格-->
        <el-table :data="priceDetailsData" border style="width: 100%">
            <!--序-->
            <el-table-column type="index"  header-align="center" align="center" :label="nowLangue.sequence"  width="40"></el-table-column>
            <el-table-column type="selection"   width="40" align="center"></el-table-column>
            <!--操作-->
            <el-table-column :label="nowLangue.operate"  width="80" header-align="center" align="center">
                <template scope="scope">
                    <!--禁用-->
                    <button class="operationItem bolder" v-if="scope.row.status" @click="handleStatus(scope.$index,scope.row)" v-text="nowLangue.forbidden" :disabled="statusDisabled"></button>
                    <!--启用-->
                    <button class="operationItem bolder" v-else @click="handleStatus(scope.$index,scope.row)" v-text="nowLangue.enable" :disabled="statusDisabled"></button>
                    <!--修改-->
                    <button class="operationItem disabled bolder" v-if="scope.row.status" v-text="nowLangue.update"></button>
                    <!--修改-->
                    <button class="operationItem bolder" v-else @click="handleUpdate(scope.$index,scope.row)"v-text="nowLangue.update"></button>
                </template>
            </el-table-column>
            <!--备件编码-->
            <el-table-column prop="bjCode" :label="nowLangue.spareCode" header-align="center" show-overflow-tooltip> </el-table-column>
            <!--备件名称-->
            <el-table-column prop="bjName" :label="nowLangue.spareName"  header-align="center" show-overflow-tooltip></el-table-column>
            <!--工厂-->
            <el-table-column prop="legalPlantCode" :label="nowLangue.factory" header-align="center" show-overflow-tooltip> </el-table-column>
            <!--价格分类-->
            <el-table-column prop="priceType" :label="nowLangue.priceClassify" header-align="center" show-overflow-tooltip> </el-table-column>
            <!--货币类型-->
            <el-table-column prop="currencyCode" :label="nowLangue.currencyType" width="60" header-align="center" show-overflow-tooltip> </el-table-column>
            <!--含税类型-->
            <el-table-column prop="taxDec" :label="nowLangue.taxType" header-align="center" show-overflow-tooltip> </el-table-column>
            <!--计量单位-->
            <el-table-column prop="materialUnit" :label="nowLangue.materialUnit"  header-align="center" show-overflow-tooltip> </el-table-column>
            <!--备件价格-->
            <el-table-column prop="price" :label="nowLangue.sparePrice" header-align="center" show-overflow-tooltip> </el-table-column>
            <!--有效开始时间-->
            <el-table-column prop="startTime" :label="nowLangue.effectiveStartTime" header-align="center" show-overflow-tooltip> </el-table-column>
            <!--有效结束时间-->
            <el-table-column prop="endTime" :label="nowLangue.effectiveEndTime" header-align="center" show-overflow-tooltip> </el-table-column>
            <!--当前状态-->
            <el-table-column prop="statusName" :label="nowLangue.currStatus" header-align="center" align="center" width="80" show-overflow-tooltip> </el-table-column>
            <!--创建人-->
            <el-table-column prop="craeteName" :label="nowLangue.founder"  header-align="center" show-overflow-tooltip> </el-table-column>
            <!--备注-->
            <el-table-column prop="remark" :label="nowLangue.memo" header-align="center" show-overflow-tooltip> </el-table-column>
            <!--法人名称-->
            <el-table-column prop="legalPersonName" :label="nowLangue.legalName"  header-align="center" show-overflow-tooltip> </el-table-column>
        </el-table>
         <!--分页-->
        <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
                       :current-page.sync="currentPage3" :current-page="pageIndex"
                       :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper"
                       :page-count="totalPage" :total="totalNumber"></el-pagination>
        <!-- 新增备件价格 -->
        <el-dialog :title="nowLangue.create + nowLangue.sparePrice" :visible.sync="dialogForm1Visible" size="small" :lock-scroll="false">
            <el-form :inline="true" :model="addSpareCostPriceForm" class="demo-form-inline label-minW100" style="border-bottom:1px solid #ccc;" ref="addSpareCostPriceForm"  >
                <!--法人名称-->
                <el-form-item :label="nowLangue.legalName" prop="legalPersonCode"  :rules="[{ required: true, message: nowLangue.required}]">
                    <el-input  size="mini" v-if="legalPersonLists.length==1" disabled v-model="addSpareCostPriceForm.legalPersonName"></el-input>
                    <!--  @change="addChangeLegalPersonCode"-->
                    <el-select size="mini" v-else v-model="addSpareCostPriceForm.legalPersonCode" :placeholder="nowLangue.pleaseSelect">
                        <el-option v-for="(legalPerson,index) in legalPersonLists" :key="index" :label="legalPerson.legalPersonName" :value="legalPerson.legalPersonCode">
                        </el-option>
                    </el-select>
                </el-form-item>
                <!--法人编码-->
                <el-form-item :label="nowLangue.legalCode" prop="legalPersonCode">
                    <el-input  size="mini" v-model="addSpareCostPriceForm.legalPersonCode" disabled></el-input>
                </el-form-item>
                <!--工厂  prop="legalPlantCode"  :rules="[{ required: true, message: nowLangue.required}]"-->
                <el-form-item :label="nowLangue.factory" v-if="factoryLists.length> 1" >
                    <el-input size="mini" disabled v-model="addSpareCostPriceForm.legalPlantCode" placeholder="" v-if="addSpareCostPriceForm.id" disabled></el-input>
                    <el-select size="mini" v-model="addSpareCostPriceForm.legalPlantCode"  :placeholder="nowLangue.pleaseSelect" v-else>
                        <el-option v-for="(legalPlantCode,index) in factoryLists" :key="index" :label="legalPlantCode.legalPlantCode" :value="legalPlantCode.legalPlantDec">
                        </el-option>
                    </el-select>
                </el-form-item>
                <!--工厂  prop="legalPlantCode"  :rules="[{ required: true, message: nowLangue.required}]"-->
                <el-form-item :label="nowLangue.factory" v-else >
                    <el-input size="mini" disabled v-model="addSpareCostPriceForm.legalPlantCode" placeholder=""></el-input>
                </el-form-item>
                <!--价格分类-->
                <el-form-item :label="nowLangue.priceClassify" prop="priceType"  :rules="[{ required: true, message: nowLangue.required}]">
                    <el-select v-model="addSpareCostPriceForm.priceType" :placeholder="nowLangue.pleaseSelect" size="mini" @change="selectedPriceType">
                        <el-option v-for="(priceType,index) in selectDropDownValueObj" :key="index" :label="priceType.priceType" :value="priceType.priceType">
                        </el-option>
                    </el-select>
                </el-form-item>
                <!--备件编码-->
                <el-form-item :label="nowLangue.spareCode" prop="materialCode"  :rules="[{ required: true, message: nowLangue.required}]" class="search-icon">
                    <el-input size="mini" v-model="addSpareCostPriceForm.materialCode" readonly icon="search"   :on-icon-click="querySpare"></el-input>
                </el-form-item>
                <!--备件名称-->
                <el-form-item :label="nowLangue.spareName" prop="materialName"  :rules="[{ required: true, message: nowLangue.required}]" label-width="76px">
                    <el-input size="mini" disabled v-model.trim="addSpareCostPriceForm.materialName"></el-input>
                </el-form-item>
                <!--货币类型-->
                <el-form-item :label="nowLangue.currencyType" prop="currencyCode"  :rules="[{ required: true, message: nowLangue.required}]">
                    <el-select v-model="addSpareCostPriceForm.currencyCode" :placeholder="nowLangue.pleaseSelect" size="mini">
                        <el-option v-for="(currencyCode,index) in selectDropDownValueObj" :key="index" :label="currencyCode.currencyCode" :value="currencyCode.currencyCode">
                        </el-option>
                    </el-select>
                </el-form-item>
                <!--含税类型-->
                <el-form-item :label="nowLangue.taxType" v-if="addSpareCostPriceForm.priceType == 1">
                    <el-input size="mini" v-model="addSpareCostPriceForm.taxDec" :title="addSpareCostPriceForm.taxDec"  disabled></el-input>
                </el-form-item>
                <!--含税类型-->
                <el-form-item :label="nowLangue.taxType" prop="taxType" v-else ">
                    <el-select v-model="addSpareCostPriceForm.taxType" :placeholder="nowLangue.pleaseSelect" size="mini">
                        <el-option v-for="(taxType,index) in taxTypeLists" :key="index" :label="taxType.taxDec" :value="taxType.id">
                        </el-option>
                    </el-select>
                </el-form-item>
                <!--备件单价-->
                <el-form-item :label="nowLangue.sparePrice"  prop="price"  :rules="[{ required: true, message: nowLangue.required}]">
                    <el-input  size="mini" v-model.trim="addSpareCostPriceForm.price" :placeholder="nowLangue.pleaseImport+nowLangue.sparePrice" @change="inputPrice"></el-input>
                </el-form-item>
                <!--价格开始时间-->
                <el-form-item :label="nowLangue.priceStartTime" prop="startTime"  :rules="[{ required: true, message: nowLangue.required}]">
                    <el-date-picker type="date" size="mini" :editable="false" v-model="addSpareCostPriceForm.startTime" :placeholder="nowLangue.pleaseSelect+nowLangue.effectiveStartTime" @change="selectedStartTime"></el-date-picker>
                </el-form-item>
                <!--价格结束时间-->
                <el-form-item :label="nowLangue.priceEndTime">
                    <el-date-picker type="date" size="mini" :editable="false" v-model="addSpareCostPriceForm.endTime" :placeholder="nowLangue.pleaseSelect+nowLangue.effectiveStartTime" @change="selectedEndTime"></el-date-picker>
                </el-form-item>
                <!--备注-->
                <el-form-item :label="nowLangue.memo">
                    <el-input size="mini" type="textarea" :rows="2" :placeholder="nowLangue.pleaseImport+nowLangue.memo" v-model="addSpareCostPriceForm.remark"></el-input>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <!--确定-->
                <el-button class="bolder outsideBtnBS" size="mini" type="danger" @click="handleAddSure" v-text="nowLangue.confirm" :disabled="addConfirmDisabled"></el-button>
                <!--取消-->
                <el-button class="bolder outsideBtnBS" size="mini" type="danger" @click="dialogForm1Visible = false" v-text="nowLangue.cancel"></el-button>
            </div>
        </el-dialog>
         <!-- 修改备件价格 -->
        <el-dialog :title="nowLangue.update + nowLangue.sparePrice" :visible.sync="dialogForm3Visible" size="small" :lock-scroll="false">
            <el-form :inline="true" :model="updateSpareCostPriceForm" class="demo-form-inline label-minW100" style="border-bottom:1px solid #ccc;" ref="updateSpareCostPriceForm"  >
                <!--法人名称-->
                <el-form-item :label="nowLangue.legalName">
                    <el-input  size="mini" v-model="updateSpareCostPriceForm.legalPersonName" disabled></el-input>
                </el-form-item>
                <!--法人编码-->
                <el-form-item :label="nowLangue.legalCode" prop="legalPersonCode">
                    <el-input  size="mini" v-model="updateSpareCostPriceForm.legalPersonCode" disabled></el-input>
                </el-form-item>
                <!--工厂-->
              <!--  <el-form-item :label="nowLangue.factory" prop="legalPlantCode"  :rules="[{ required: true, message: nowLangue.required}]">
                    <el-input size="mini" disabled v-model="updateSpareCostPriceForm.legalPlantCode" placeholder="" disabled></el-input>
                </el-form-item>-->
                <!--价格分类-->
                <el-form-item :label="nowLangue.priceClassify" prop="priceType"  >
                    <el-input  size="mini" v-model="updateSpareCostPriceForm.priceTypeName" disabled></el-input>
                </el-form-item>
                <!--备件编码-->
                <el-form-item :label="nowLangue.spareCode" prop="materialCode"   class="search-icon">
                    <el-input size="mini" v-model="updateSpareCostPriceForm.materialCode"  disabled></el-input>
                </el-form-item>
                <!--备件名称-->
                <el-form-item :label="nowLangue.spareName" prop="materialName" >
                    <el-input size="mini" disabled v-model="updateSpareCostPriceForm.materialName"></el-input>
                </el-form-item>
                <!--货币类型-->
                <el-form-item :label="nowLangue.currencyType" prop="currencyCode" >
                    <el-input size="mini" v-model="updateSpareCostPriceForm.currencyCodeName" disabled ></el-input>
                </el-form-item>
                <!--含税类型-->
                <el-form-item :label="nowLangue.taxDec" v-if="updateSpareCostPriceForm.taxDec == 1">
                    <el-input size="mini" v-model="updateSpareCostPriceForm.taxDec" :title="updateSpareCostPriceForm.taxDec"  disabled></el-input>
                </el-form-item>
                <!--含税类型-->
                <el-form-item :label="nowLangue.taxDec" prop="taxDec" v-else >
                    <el-input size="mini" v-model="updateSpareCostPriceForm.taxDec" :title="updateSpareCostPriceForm.taxDec" disabled ></el-input>
                </el-form-item>
                <!--备件价格-->
                <el-form-item :label="nowLangue.sparePrice"  prop="price"  >
                    <el-input  size="mini" v-model="updateSpareCostPriceForm.price" :placeholder="nowLangue.pleaseImport+nowLangue.sparePrice" @change="inputPrice"></el-input>
                </el-form-item>
                <!--价格开始时间-->
                <el-form-item :label="nowLangue.priceStartTime" prop="startTime"  >
                    <el-date-picker type="date" size="mini" :editable="false"  v-model="updateSpareCostPriceForm.startTime" disabled:placeholder="nowLangue.pleaseSelect+nowLangue.effectiveStartTime"></el-date-picker>
                </el-form-item>
                <!--价格结束时间-->
                <el-form-item :label="nowLangue.priceEndTime">
                    <el-date-picker type="date" size="mini" :editable="false" v-model="updateSpareCostPriceForm.endTime":placeholder="nowLangue.pleaseSelect+nowLangue.effectiveStartTime" @change="updateSelectedEndTime"></el-date-picker>
                </el-form-item>
                <!--备注-->
                <el-form-item :label="nowLangue.memo">
                    <el-input size="mini" type="textarea" :rows="2" :placeholder="nowLangue.pleaseImport+nowLangue.memo" v-model="updateSpareCostPriceForm.remark"></el-input>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <!--确定-->
                <el-button class="bolder outsideBtnBS" size="mini" type="danger" @click="handleUpdateSure" v-text="nowLangue.confirm" :disabled="updateConfirmDisabled"></el-button>
                <!--取消-->
                <el-button class="bolder outsideBtnBS" size="mini" type="danger" @click="dialogForm3Visible = false" v-text="nowLangue.cancel"></el-button>
            </div>
        </el-dialog>
         <!--选择备件弹窗-->
        <!--选择备件-->
        <el-dialog :title="nowLangue.selectSpare" :visible.sync="dialogForm2Visible" :lock-scroll="false">
            <el-form :model="chooseSpare" :inline="true">
                <!--备件编号-->
                <el-form-item :label="nowLangue.spareCode" >
                    <el-input size="mini" v-model="chooseSpare.bjCode" auto-complete="off" :placeholder="nowLangue.pleaseImport+nowLangue.spareCode"></el-input>
                </el-form-item>
                <!--备件名称-->
                <el-form-item :label="nowLangue.spareName" >
                    <el-input size="mini" v-model="chooseSpare.bjName" auto-complete="off" :placeholder="nowLangue.pleaseImport+nowLangue.spareName"></el-input>
                </el-form-item>
                <el-form-item>
                    <!--查询-->
                    <el-button type="danger" class="bolder outsideBtnBS selectAll" :disabled="select2Disabled" size="mini" @click="querySpare()" v-text="nowLangue.query"></el-button>
                    <!--确定-->
                    <el-button type="danger" class="bolder outsideBtnBS" size="mini" @click="insertMateraialSupplier" v-text="nowLangue.confirm"></el-button>
                </el-form-item>
            </el-form>
            <el-table :data="spareListDate" border style="margin-top:16px;width: 100%;" v-loading.body="spareLoading" element-loading-text="拼命加载中">
                <!--序-->
                <el-table-column type="index" header-align="center" align="center" :label="nowLangue.sequence"  width="40"></el-table-column>
                <!--选择-->
                <el-table-column :label="nowLangue.select" header-align="center" align="center" width="40">
                    <template scope="scope">
                        &nbsp;<el-radio v-model="defaultSpareCode" :label="scope.row.bjCode" :value="scope.row.bjName" size="mini">&nbsp;</el-radio>
                    </template>
                </el-table-column>
                <!--备件编码-->
                <el-table-column prop="bjCode" :label="nowLangue.code" header-align="center" show-overflow-tooltip></el-table-column>
                <!--备件名称-->
                <el-table-column prop="bjName" :label="nowLangue.name" header-align="center" show-overflow-tooltip></el-table-column>
            </el-table>
            <!--分页-->
            <el-pagination v-if="spareIsPaging" @size-change="handleSpareSizeChange" @current-change="handleSpareCurrentChange"  :current-page.sync="currentPage3" :current-page="PageIndex"   :page-sizes="[5, 10, 15 , 20, 25]" :page-size="sparePageSize" layout="total, sizes, prev, pager, next, jumper" :page-count="spareTotalPage" :total="spareTotalNumber"></el-pagination>
        </el-dialog>
        <!--导入弹框-->
        <!--导入备件价格-->
        <el-dialog :title="nowLangue.import+nowLangue.sparePrice" id="importFile" :visible.sync="importFileVisible" size="tiny" :lock-scroll="false">
             <el-form :model="importFileForm" :inline="true" ref="importFileForm" label-width="112px">
                 <!--请选择法人信息-->
                <el-form-item :label="nowLangue.legalName"  prop="legalPersonName"  :rules="[{ required: true, message: nowLangue.required}]">
                    <el-input size="mini" v-if="legalPersonLists.length==1" disabled v-model="importFileForm.legalPersonName" disabled ></el-input>
                    <el-select size="mini" v-else v-model="importFileForm.legalPersonName" :placeholder="nowLangue.pleaseSelect" @change="changeLegalPerson"> 
                        <el-option v-for="(legalPerson,index) in legalPersonLists" :key="index" :label="legalPerson.legalPersonName" :value="legalPerson.legalPersonName">
                        </el-option>
                    </el-select>
                </el-form-item>
                 <!--请选择价格分类-->
                <el-form-item :label="nowLangue.priceClassify"   prop="priceType"  :rules="[{ required: true, message: nowLangue.required}]">
                    <el-select v-model="importFileForm.priceType" :placeholder="nowLangue.pleaseSelect" size="mini" @change="changePriceType">
                        <el-option v-for="(priceType,index) in selectDropDownValueObj.jizhang" :key="index" :label="priceType.label" :value="priceType.value">
                        </el-option>
                    </el-select>
                </el-form-item>
                 <!--请选择导入文件-->
                <el-form-item :label="nowLangue.import+nowLangue.file" >
                    <el-upload class="upload-demo"  :action="action" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel" :on-preview="handlePreview" :on-remove="handleRemove" :file-list="fileList" :before-upload="beforeAvatarUpload" :on-success="handleAvatarSuccess" :data="{legalPersonName:importFileForm.legalPersonName,legalPersonCode:importFileForm.legalPersonCode, priceTypeName:importFileForm.priceTypeName,priceType:importFileForm.priceType}">
                        <!--点击上传-->
                        <el-button size="mini" type="danger" style="margin-right:20px;" v-text="nowLangue.clickUpload"></el-button>
                        <!--只能上传excel文件-->
                        <div slot="tip" class="el-upload__tip" v-text="nowLangue.uploadTip"></div>
                    </el-upload>
                </el-form-item>
            </el-form>
        </el-dialog>

    </div>
</template>

<script>
    export default {
        data(){
            return{
                nowLangue:{},
                legalPersonLists:[],   //法人名称下拉列表中的值
                factoryLists:[],    //工厂下来列表中的值
                taxTypeLists:[],    //含税类型下拉列表中的值
                selectDropDownValueObj:{},  // 查询条件 价格分类、币别、当前状态下拉列表三个下拉框
                spareCostPriceForm:{
                    legalPersonName:'',
                    legalPersonId:'',
                    legalPersonCode:'',
                    legalPlantCode:'',
                    taxType:'',   //含税类型
                    priceType:'',    //价格类别
                    currencyCode:'',
                    materialCode:'',
                    startStartTime:'',
                    startEndTime:'',
                    endStartTime:'',
                    endEndTime:'',   
                    status:'',  // 当前状态
                },
                pageIndex: 1,    //当前页（必传）
                pageSize: 10,   //每页多少条
                currentPage3:3,
                totalNumber: 20,
                totalPage: 2,
                priceDetailsData:[],
                dialogForm1Visible:false,   //新增备件价格弹窗
                addSpareCostPriceForm:{      //新增备件价格表单
                    legalPersonName:"",//法人名称
                    legalPersonCode:"",//法人编码
                    currencyCode:"",//币别
                    materialCode:"",//备件编码
                    priceType:"",//价格分类
                    startTime:"",//开始时间
                    endTime:"",//结束时间
                    materialName:"",//备件名称
                    price:"",//备件单价
                    taxType:"",//含税类型
                    legalPlantCode:"",//工厂编号
                    remark:""//备注
                },
                dialogForm3Visible:false,   //修改备件价格弹窗
                updateSpareCostPriceForm:{      //修改备件价格表单
                    legalPersonName:"",//法人名称
                    legalPersonCode:"",//法人编码
                    currencyCode:"",//币别
                    currencyCodeName:"",//币别
                    materialCode:"",//备件编码
                    priceType:"",//价格分类
                    priceTypeName:"",//价格分类
                    startTime:"",//开始时间
                    endTime:"",//结束时间
                    materialName:"",//备件名称
                    price:"",//备件单价
                    taxType:"",//含税类型
                    taxDec:"",
                    legalPlantCode:"",//工厂编号
                    remark:""//备注
                },
                dialogForm2Visible:false, // 选择备件弹窗
                chooseSpare:{
                    code:"",
                    name:""
                },
                priceIsNumber:true,   //备件单价位数字
                spareListDate:[],   // 选择备件弹窗 中的数据
                defaultSpareCode:"",   //只能选中一个备件编码
                defaultSpareName:"",
                spareIsPaging:false,
                spareLoading:false,
                PageIndex: 1,    //当前页（必传）
                sparePageSize: 10,   //每页多少条
                spareTotalNumber: 20,
                spareTotalPage: 2,
                currentPage3: 3,

                action:"",
                fileList: [],
                importFileVisible:false,
                importFileForm:{
                    legalPersonName:"",//法人名称
                    legalPersonCode:"",//法人编码
                    priceTypeName:"",//价格分类
                    priceType:"",//价格分类
                },
                //权限
                powerFlag1:false,
                powerFlag2:false,
                powerFlag3:false,
                //查询禁用
                selectDisabled:false,                
                select2Disabled:false,    // 查询备件操作按钮禁用
                statusDisabled:false,    //启用禁用操作按钮禁用
                addConfirmDisabled:false,     //新增弹窗中确定操作按钮禁用
                updateConfirmDisabled:false,     //修改弹窗中确定操作按钮禁用
            }
        },
        created:function(){
            var _this=this;
            _this.languageType=="zh"?_this.nowLangue=_this.language.zh:_this.nowLangue=_this.language.en;
        },
        computed:{
            powerData(){
                return this.$store.state.powerData;
            },
            languageType(){
                return this.$store.state.languageType;
            }
        },
        watch:{
            languageType(){
                var _this=this;
                _this.languageType=="zh"?_this.nowLangue=_this.language.zh:_this.nowLangue=_this.language.en;
            }
        },
        mounted:function(){
            var _this=this;
            _this.$store.commit('currentActive', 'SpareCostPrice');
            // //ajax前后查询按钮禁用
            // $(".selectAll").ajaxStart(function(){
            //     _this.selectDisabled=true;
            // });
            // $(".selectAll").ajaxStop(function(){
            //     _this.selectDisabled=false;
            // });
            // 获取当前系统的时间
            var myDate=new Date();
            _this.spareCostPriceForm.createTimeEnd=myDate.getFullYear()+"-"+(myDate.getMonth()+1)+"-"+myDate.getDate();
            _this.spareCostPriceForm.createTimeBegin=myDate.getFullYear()+"-"+(myDate.getMonth()+1)+"-"+(myDate.getDate()-7);
            _this.legalPersonDropDownValue();  // 查询条件 法人名称 下拉列表的值 
            _this.taxTypeDropDownValue();    // 查询条件 含税类型下拉列表
            _this.selectDropDownValue(); // 查询条件 价格分类、币别、当前状态下拉列表三个下拉框
           _this.handleQuery();    // 按计划汇总   查询

            
            // 上传地址
            _this.action=_this.metadata_service+"SparePartsCost/SparePartsCostIntroduction";
            //判断权限
            // for(var i=0;i<_this.powerData.length;i++){
            //     if(_this.powerData[i]=="ROLE_security_materialPlan_modify"){
            //         //备件计划新增、修改、保存、提交及导入权限
            //         _this.powerFlag1=true;
            //     }
            //     if(_this.powerData[i]=="ROLE_security_materialPlan_review"){
            //         //备件计划审核权限
            //         _this.powerFlag2=true;
            //     }
            //     if(_this.powerData[i]=="ROLE_security_materialPlan_approve"){
            //         //备件计划审批权限
            //         _this.powerFlag3=true;
            //     }
            // }

        },
        methods:{
            // 查询条件 法人名称 下拉列表的值
            legalPersonDropDownValue(){  //法人名称下拉列表值
                var _this = this;
                $.ajax({
                    type:'GET',
                    url:_this.procurement_service+"legalPerson/ofCurrentUser",
                    cache:false,
                    success:function(data){
                        if(data.success){
                            _this.legalPersonLists = data.data;
                            if(_this.legalPersonLists.length == 1){
                                // _this.spareCostPriceForm.legalPersonId =_this.legalPersonLists[0].id;
                                // _this.spareCostPriceForm.legalPersonCode =_this.legalPersonLists[0].legalPersonCode;
                                // _this.spareCostPriceForm.legalPersonName =_this.legalPersonLists[0].legalPersonName;
                                if(_this.importFileForm){
                                    _this.importFileForm.legalPersonId =_this.legalPersonLists[0].id;
                                    _this.importFileForm.legalPersonCode =_this.legalPersonLists[0].legalPersonCode;
                                    _this.importFileForm.legalPersonName =_this.legalPersonLists[0].legalPersonName;
                                }
                            }
                            _this.factoryDropDownValue(_this.spareCostPriceForm.legalPersonCode);
                        }else{
                            _this.common.errorTip(data.errorMessage);
                        }
                    }
                })
            },
            // 下拉列表选择法人名称
            selectLegalPersonCode(){
                var _this=this; 
                _this.spareCostPriceForm.legalPlantCode = "";
                _this.spareCostPriceForm.legalPersonCode = "";
                for(var i=0;i<_this.legalPersonLists.length;i++){
                    if(_this.spareCostPriceForm.legalPersonName==_this.legalPersonLists[i].legalPersonName){
                        _this.spareCostPriceForm.legalPersonId=_this.legalPersonLists[i].id;
                        _this.spareCostPriceForm.legalPersonCode=_this.legalPersonLists[i].legalPersonCode;
                    }
                }
                _this.factoryDropDownValue(_this.spareCostPriceForm.legalPersonCode);
            },
            // 查询条件 工厂下拉列表 根据法人code查
            factoryDropDownValue(legalPersonCode){
                var _this = this;
                $.ajax({
                    type:'GET',
                    url:_this.metadata_service+"materialCostPrice/queryPlantListByLegalPersonCode?legalPersonCode="+legalPersonCode,
                    cache:false,
                    success:function(data){
                        if(data.success){
                            _this.factoryLists = data.data;
//                            if(_this.factoryLists.length == 1){
//                                _this.spareCostPriceForm.legalPlantCode = data.data[0];
//                                _this.addSpareCostPriceForm.legalPlantCode = data.data[0];
//                            }
                        }else{
                            _this.common.errorTip(data.errorMessage);
                        }
                    }
                })
            },
            // 查询条件 含税类型下拉列表
            taxTypeDropDownValue(){
                var _this=this;
                $.ajax({
                    type:'GET',
                    url:_this.metadata_service+"Price/queryAllTaxType",
                    cache:false,
                    success:function(data){
                        if(data.success){
                            _this.taxTypeLists = data.data;
                        }else{
                            _this.common.errorTip(data.errorMessage);
                        }
                    }
                })
            },
            // 查询条件 价格分类、币别、当前状态下拉列表三个下拉框
            selectDropDownValue(){
                var _this=this;
                var tmp=["materialCostPrice.materialCostPriceStatus","materialCostPrice.priceType","currencyCode"];
                $.ajax({
                    type: 'POST',
                    url: _this.metadata_service+"price/getPullDownList",
                    cache: false,
                    data:JSON.stringify(tmp),
                    dataType:'JSON',
                    contentType: "application/json;charset=utf-8",     //*****
                    success: function (data) {
                        if (data.success) {
                            _this.selectDropDownValueObj=data.data;
                        }else                            
                            _this.common.errorTip(data.errorMessage);
                    }
                });
            },
            // 有效开始时间格式化
            selectedStartStartTime(val){
                var _this=this;
                _this.spareCostPriceForm.startStartTime = val;
                if(_this.spareCostPriceForm.startEndTime && val > _this.spareCostPriceForm.startEndTime){
                    var err=_this.languageType=="zh"?"有效开始时间的起始时间不能大于有效开始时间的结束时间！":"The starting time of the effective start time must not be greater than the end time of the effective start time";
                    _this.common.errorTip(err);
                    _this.spareCostPriceForm.startStartTime = "";
                };
            },
            selectedStartEndTime(val){
                var _this=this;
                _this.spareCostPriceForm.startEndTime = val;
                if(_this.spareCostPriceForm.startStartTime && val < _this.spareCostPriceForm.startStartTime){
                    var err=_this.languageType=="zh"?"有效开始时间的结束时间不能小于有效开始时间的起始时间！":"The end time of the effective start time must not be less than the start time of the valid start time";
                    _this.common.errorTip(err);
                    _this.spareCostPriceForm.startEndTime = "";
                };
            },
            // 有效结束时间格式化
            selectedEndStartTime(val){
                var _this=this;
                _this.spareCostPriceForm.endStartTime = val;
                if(_this.spareCostPriceForm.endEndTime && val > _this.spareCostPriceForm.endEndTime){  
                    var err=_this.languageType=="zh"?"有效结束时间的起始时间不能大于有效结束时间的结束时间！":"The starting time of the effective end time must not be greater than the end time of the effective end time";
                    _this.common.errorTip(err);
                    _this.spareCostPriceForm.endStartTime = "";
                };
            },
            selectedEndEndTime(val){
                var _this=this;
                _this.spareCostPriceForm.endEndTime = val;
                if(_this.spareCostPriceForm.endStartTime && val < _this.spareCostPriceForm.endStartTime){
                    var err=_this.languageType=="zh"?"有效结束时间的结束时间不能小于有效结束时间的起始时间！":"The end time of the effective end time must not be less than the starting time of the effective end time";
                    _this.common.errorTip(err);
                    _this.spareCostPriceForm.endEndTime = "";
                };
            },
            // 查询按钮
            handleQuery(){
                var _this=this;
                _this.loading=true;
                var tmp={
                    legalPersonCode:_this.spareCostPriceForm.legalPersonCode,
                    legalPlantCode:_this.spareCostPriceForm.legalPlantCode,
                    bjCode:_this.spareCostPriceForm.bjCode,
//                    taxType:_this.spareCostPriceForm.taxType,
                    priceType:_this.spareCostPriceForm.priceType,
                    currencyCode:_this.spareCostPriceForm.currencyCode,
                    startStartTime:_this.spareCostPriceForm.startStartTime,
                    startEndTime:_this.spareCostPriceForm.startEndTime,
                    endStartTime:_this.spareCostPriceForm.endStartTime,
                    endEndTime:_this.spareCostPriceForm.endEndTime,
                    // creatorName:_this.spareCostPriceForm.creatorName,
                    status:_this.spareCostPriceForm.status,
                    pageIndex:_this.pageIndex,
                    pageSize:_this.pageSize};
                // 如果计划来源有值，添加这个参数
                if(_this.spareCostPriceForm.source){
                    tmp.source=_this.spareCostPriceForm.source;
                }
                _this.selectDisabled=true;
                $.ajax({
                    type: 'POST',
                    url: _this.metadata_service+"Price/queryPage",
                    cache: false,
                    data:JSON.stringify(tmp),
                    dataType:'JSON',
                    contentType: "application/json;charset=utf-8",     //*****
                    success: function (data) {
                        if (data.success) {
                            _this.loading=false;
                            var arr=data.data.dataList;
//                            //单价保留两位
//                            for(var i=0;i<arr.length;i++){
//                                arr[i].price=arr[i].price.toFixed(2);
//                           }
                            _this.priceDetailsData=arr;
                            _this.totalNumber=data.data.totalNumber;    //总条数
                            _this.totalPage=data.data.totalPage;    //总页数 
                        }else{
                            _this.common.errorTip(data.errorMessage);
                        }                          
                        _this.selectDisabled=false;    
                    }
                });
            },
            //   分页
            handleSizeChange(val) {
                var _this = this;
                _this.pageSize=val;
                _this.handleQuery();
            },
            //点击页码分页查询点击事件
            handleCurrentChange(val) {
                var _this = this;
                _this.pageIndex=val;
                _this.handleQuery();
            },
            //新增按钮
            createNew(){
                var _this=this; 
                if(_this.$refs['addSpareCostPriceForm']) {
                    _this.$refs['addSpareCostPriceForm'].resetFields();
                }
                _this.addSpareCostPriceForm.id ="";
                _this.addSpareCostPriceForm.legalPersonName ="";
                _this.addSpareCostPriceForm.legalPersonCode ="";
                _this.addSpareCostPriceForm.currencyCode ="";
                _this.addSpareCostPriceForm.materialCode ="";
                _this.addSpareCostPriceForm.priceType ="";
                _this.addSpareCostPriceForm.startTime ="";
                _this.addSpareCostPriceForm.endTime ="";
                _this.addSpareCostPriceForm.materialName ="";
                _this.addSpareCostPriceForm.price ="";
                _this.addSpareCostPriceForm.taxType ="";
                _this.addSpareCostPriceForm.legalPlantCode ="";
                _this.addSpareCostPriceForm.remark ="";
                _this.dialogForm1Visible=true;
            },
            // 新增弹窗中法人名称   取法人code
            addChangeLegalPersonCode(){
                var _this=this; 
                // if(_this.factoryLists.length > 1){
                    _this.addSpareCostPriceForm.legalPlantCode = "";
                // }
                for(var i=0;i<_this.legalPersonLists.length;i++){
                    if(_this.addSpareCostPriceForm.legalPersonName==_this.legalPersonLists[i].legalPersonName){
                        _this.addSpareCostPriceForm.legalPersonCode=_this.legalPersonLists[i].legalPersonCode;
                    }
                }
                _this.factoryDropDownValue(_this.addSpareCostPriceForm.legalPersonCode);
            },
            // 新增备件价格时  选择价格分类时，清空含税类型
            selectedPriceType(){
                var _this = this;
                if(_this.addSpareCostPriceForm.priceType == 1){
                    _this.addSpareCostPriceForm.taxType = "";
                }
            },
            // 备件编码  选择备件弹窗
            querySpare(ev){
                var _this=this;
                _this.dialogForm2Visible = true;
                _this.spareLoading=true;
                _this.defaultSpareCode = "";
                var tmp={code:_this.chooseSpare.code,name:_this.chooseSpare.name,pageIndex:_this.PageIndex,pageSize :_this.sparePageSize};
                _this.select2Disabled=true;
                $.ajax({
                    type: 'POST',
                    url: _this.metadata_service+"part/queryB",
                    cache: false,
                    data:JSON.stringify(tmp),
                    dataType:'JSON',
                    contentType: "application/json;charset=utf-8",     //*****
                    success: function (data) {
                        if (data.success) {
                            _this.spareLoading=false;
                            _this.spareIsPaging=true; 
                            _this.spareListDate=data.data.dataList;
                            _this.spareTotalNumber=data.data.totalNumber;    //总条数
                            _this.spareTotalPage=data.totalPage;    //总页数
                        }else{
                            _this.common.errorTip(data.errorMessage);
                        }                           
                        _this.select2Disabled=false;    
                    }
                });
            },
            // 分页
            handleSpareSizeChange(val){
                var _this = this;
                _this.sparePageSize=val;
                _this.querySpare();
            },
            //点击页码分页查询点击事件
            handleSpareCurrentChange(val){
                var _this = this;
                _this.sparePageIndex=val;
                _this.querySpare();
            },
            // 选择备件弹窗  确定按钮
            insertMateraialSupplier(){
                var _this=this;
                if(_this.defaultSpareCode){
                    _this.dialogForm2Visible = false;
                    for(var i=0;i<_this.spareListDate.length;i++){
                        if(_this.defaultSpareCode == _this.spareListDate[i].bjCode){
                            _this.defaultSpareName = _this.spareListDate[i].bjName;
                        }
                    }
                    _this.addSpareCostPriceForm.materialCode = _this.defaultSpareCode;
                    _this.addSpareCostPriceForm.materialName = _this.defaultSpareName;
                }else{
                    var err=_this.languageType=="zh"?"请选择备件！":"Please select spare parts";
                    _this.common.errorTip(err);
                }                
            },
            // 输入备件单价
            inputPrice(val){
                var _this=this;
                if(!(/^\d+(\.\d+)?$/.test(val))){
                    var err=_this.languageType=="zh"?"备件单价必须为数字！":"The unit price of spare parts must be digital";
                    _this.common.errorTip(err);
                    _this.priceIsNumber=false;
                }else{
                    _this.priceIsNumber= true;
                }
            },
            // 弹窗中 价格开始时间格式化
            selectedStartTime(val){
                var _this = this;
                _this.addSpareCostPriceForm.startTime = val;
                if(_this.addSpareCostPriceForm.endTime && val >= _this.addSpareCostPriceForm.endTime){
                    var err=_this.languageType=="zh"?"价格开始日期不能大于等于价格结束日期！":"The price start date must not be greater than the end date of the price";
                    _this.common.errorTip(err);
                    _this.addSpareCostPriceForm.startTime = "";
                };
            },
            // 弹窗中 价格结束时间格式化
            selectedEndTime(val){
                var _this = this;
                _this.addSpareCostPriceForm.endTime = val;
                if(_this.addSpareCostPriceForm.startTime && val <= _this.addSpareCostPriceForm.startTime){
                    var err=_this.languageType=="zh"?"价格结束日期不能小于等于价格开始日期！":"The end of the price shall not be less than or equal to the date of commencement of the price";
                    _this.common.errorTip(err);
                    _this.addSpareCostPriceForm.endTime = "";
                };
            },
            // 修改弹窗中 价格结束时间格式化
            updateSelectedEndTime(val){
                var _this = this;
                _this.updateSpareCostPriceForm.endTime = val;
                if(_this.updateSpareCostPriceForm.startTime && val <= _this.updateSpareCostPriceForm.startTime){
                    var err=_this.languageType=="zh"?"价格结束日期不能小于等于价格开始日期！":"The end of the price shall not be less than or equal to the date of commencement of the price";
                    _this.common.errorTip(err);
                    _this.updateSpareCostPriceForm.endTime = "";
                };
            },
            // 新增备件价格弹窗 确定按钮
            handleAddSure(){
                var _this=this;
                 this.$refs['addSpareCostPriceForm'].validate((valid) => {
                    if (valid) {
                        // 新增
                        var tmp={legalPersonName:_this.addSpareCostPriceForm.legalPersonName,
                                legalPersonCode:_this.addSpareCostPriceForm.legalPersonCode,
                                currencyCode:_this.addSpareCostPriceForm.currencyCode,
                                materialCode:_this.addSpareCostPriceForm.materialCode,
                                priceType:_this.addSpareCostPriceForm.priceType,
                                startTime:_this.addSpareCostPriceForm.startTime,
                                endTime:_this.addSpareCostPriceForm.endTime,
                                materialName:_this.addSpareCostPriceForm.materialName,
                                price:_this.addSpareCostPriceForm.price,
                                taxType:_this.addSpareCostPriceForm.taxType,
                                legalPlantCode:_this.addSpareCostPriceForm.legalPlantCode,
                                remark:_this.addSpareCostPriceForm.remark};
                        var urlPath = _this.metadata_service+"Price/add";
                        if(_this.priceIsNumber){
                            _this.addConfirmDisabled=true;
                            $.ajax({
                                type: 'POST',
                                url: urlPath,
                                cache: false,
                                data:JSON.stringify(tmp),
                                dataType:'JSON',
                                contentType: "application/json;charset=utf-8",
                                success: function (data) {
                                    if (data.success) {
                                        _this.dialogForm1Visible=false;
                                        var success=_this.languageType=="zh"?'新增成功！':'New success';
                                        _this.common.successTip(success);
                                        _this.handleQuery();
                                    }else{
                                        _this.common.errorTip(data.errorMessage);
                                    }
                                    _this.addConfirmDisabled=false;    
                                }
                            });
                        }else{
                            var err=_this.languageType=="zh"?"备件单价必须为数字！":"The unit price of spare parts must be digital";
                            _this.common.errorTip(err);
                        }
                    } else {
                        var  err=_this.common.formErrorInfo();
                        _this.common.errorTip(err);
                    }
                });
            },
            // 修改按钮
            handleUpdate(index,row){
                var _this=this; 
                _this.updateSpareCostPriceForm.id =row.id;
                _this.updateSpareCostPriceForm.legalPersonName =row.legalPersonName;
                _this.updateSpareCostPriceForm.legalPersonCode =row.legalPersonCode;
                _this.updateSpareCostPriceForm.currencyCode =row.currencyCode;
                _this.updateSpareCostPriceForm.currencyCodeName =row.currencyCodeName;
                _this.updateSpareCostPriceForm.materialCode =row.materialCode;
                _this.updateSpareCostPriceForm.priceType =row.priceType;
                _this.updateSpareCostPriceForm.priceTypeName =row.priceTypeName;
                _this.updateSpareCostPriceForm.startTime =row.startTime;
                _this.updateSpareCostPriceForm.endTime =row.endTime;
                _this.updateSpareCostPriceForm.materialName =row.materialName;
                _this.updateSpareCostPriceForm.price =row.price;
                _this.updateSpareCostPriceForm.taxType =row.taxType;
                _this.updateSpareCostPriceForm.taxDec =row.taxDec;
                _this.updateSpareCostPriceForm.legalPlantCode =row.legalPlantCode;
                _this.updateSpareCostPriceForm.remark =row.remark;
                _this.dialogForm3Visible=true;
            },
            // 修改备件价格弹窗 确定按钮
             handleUpdateSure(){
                var _this=this;
                 this.$refs['updateSpareCostPriceForm'].validate((valid) => {
                    if (valid) {
                        var tmp={id:_this.updateSpareCostPriceForm.id,
                            endTime:_this.updateSpareCostPriceForm.endTime,
                            price:_this.updateSpareCostPriceForm.price,
                            remark:_this.updateSpareCostPriceForm.remark};
                        if(_this.priceIsNumber){
                            _this.updateConfirmDisabled=true;
                            $.ajax({
                                type: 'POST',
                                url: _this.metadata_service+"Price/update",
                                cache: false,
                                data:JSON.stringify(tmp),
                                dataType:'JSON',
                                contentType: "application/json;charset=utf-8",
                                success: function (data) {
                                    if (data.success) {
                                        _this.dialogForm3Visible=false;
                                        var success=_this.languageType=="zh"?'修改成功！':'Modify successfully';
                                        _this.common.successTip(success);
                                        _this.handleQuery();
                                    }else{
                                        _this.common.errorTip(data.errorMessage);
                                    }
                                    _this.updateConfirmDisabled=false;    
                                }
                            });
                        }else{
                            var err=_this.languageType=="zh"?"备件单价必须为数字！":"The unit price of spare parts must be digital";
                            _this.common.errorTip(err);
                        }
                    } else {
                        var  err=_this.common.formErrorInfo();
                        _this.common.errorTip(err);
                    }
                });
            },
            //导入按钮
            importFile(){
                var _this=this;
                _this.importFileVisible = true;
                _this.importFileForm.legalPersonName = "";
                _this.importFileForm.priceType = "";
                _this.fileList=[];
            },
            // 导入弹框中 法人信息
            changeLegalPerson(){
                var _this=this;
                for(var i=0;i<_this.legalPersonLists.length;i++){
                    if(_this.importFileForm.legalPersonName == _this.legalPersonLists[i].legalPersonName){
                        _this.importFileForm.legalPersonCode = _this.legalPersonLists[i].legalPersonCode;
                    }
                }
            },
            //  导入弹框中 价格分类取name
            changePriceType(){
                var _this=this;
                for(var i=0;i<_this.selectDropDownValueObj['materialCostPrice.priceType'].length;i++){
                    if(_this.importFileForm.priceType == _this.selectDropDownValueObj['materialCostPrice.priceType'][i].value){
                        _this.importFileForm.priceTypeName = _this.selectDropDownValueObj['materialCostPrice.priceType'][i].label;
                    }
                }
            },
            //上传文件之前的钩子
            beforeAvatarUpload(file) {
                // console.log(file);
                var _this = this;
                _this.$refs["importFileForm"].validate((valid) => {
                    if (valid) {
                        const isExcel2007 = file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';   // 2010
                        const isExcel2003 = file.type === 'application/vnd.ms-excel';
                        if (!isExcel2007 && !isExcel2003) {
                            //只能上传excel文件
                            this.$message.error(_this.nowLangue.uploadTip);
                        }
                        return isExcel2007 || isExcel2003 ;
                    } else {
                        var  err=_this.common.formErrorInfo();
                        _this.common.errorTip(err);
                        return false;
                    }
                });
            },
            // 文件上传成功时的钩子
             handleAvatarSuccess(res, file) {
                 var _this=this;
                if(res.success){
                    var success = _this.languageType == "zh" ? "上传成功！" : "Upload successfully";
                    _this.common.successTip(success);
                    _this.importFileVisible = false;
                    //上传成功刷新页面
                    _this.handleQuery();    
                }else{
                    _this.fileList=[];
                    _this.common.errorTip(res.errorMessage);
                }
            },
            handleRemove(file, fileList) {
                console.log(file, fileList);
            },
            handlePreview(file) {
                console.log(file);
            },
            // 操作启用禁用
            handleStatus(index, row){
                var _this=this;
                var tmp={id:row.id,status:!row.status};
                _this.statusDisabled=true;
                $.ajax({
                    type: 'POST',
                    url: _this.metadata_service+"Price/updateStatus",
                    cache: false,
                    data:JSON.stringify(tmp),
                    dataType:'JSON',
                    contentType: "application/json;charset=utf-8",     //*****
                    success: function (data) {
                        if (data.success) {
                            _this.handleQuery();
                            var success = _this.languageType == "zh" ? "操作成功！" : "Successful operation";
                            _this.common.successTip(success);
                        }else{
                            _this.common.errorTip(data.errorMessage);
                        }                        
                        _this.statusDisabled=false;    
                    }
                });
            }
        }
    }
</script>


<style>
    .el-form-item__content{
        display: inherit;
    }
    .searchBtn{
        box-shadow: 1px 1px 3px #000;
    }
    .jumpBtn{
        float: right;
    }
    .routerMR10{
        margin-right: 10px;
    }
    .routerML30{
        margin-left: 30px;
    }
</style>